﻿#ifndef DIALOGONLINE_H
#define DIALOGONLINE_H

#include <QDialog>
#include <QTcpSocket>

enum upIndex{
    SHOW_SLEF,
    CLOSE_SELF,
    SHOW_RIVAL,
    CLOSE_RIVAL
};

class QLabel;

namespace Ui {
class dialogOnline;
}

class dialogOnline : public QDialog
{
    Q_OBJECT

public:
    explicit dialogOnline(QWidget *parent, QTcpSocket* tempSocket);
    ~dialogOnline();

private slots:
    void on_exitBtn_clicked();

signals:
    void signal_exit();
    void signal_succ(); // 网络匹配成功

protected:
    void closeEvent(QCloseEvent *);

private:
    void init();
    void paintEvent(QPaintEvent *event);
    void updateHead(upIndex index); // 更新头像
    void tcpInfoHandle();
    void tcpInfoResponse(QString str);
    QPixmap getRoundHead(const QPixmap& src, QPixmap& mask, QSize maskSize);

private:
    Ui::dialogOnline *ui;
    QTcpSocket* m_tcpSocket;
    QString gTcpIP = "127.0.0.1";
    int gTcpPort = 8808;

};

#endif // DIALOGONLINE_H
